package jym.tan.tmdb.method.get;

import java.net.URL;

import jym.tan.tmdb.TMDB;
import jym.tan.tmdb.bean.wrapper.PersonCreditWrapper;
import jym.tan.tmdb.constant.TMDBConstants;
import jym.tan.tmdb.method.Base;

/**
 * The Class PersonCredits. This class is similar to the <b>Person Credits</b> method described in 
 * <a href="http://help.themoviedb.org/kb/api/person-credits">Person Credits</a>.
 * This method is used to retrieve all of the cast & crew information for the person. It will return 
 * the single highest rated poster for each movie record.
 * @author Tanmoy
 */
public class PersonCredits extends Base {

	/**
	 * Instantiates a new PersonCredits.
	 *
	 * @param tmdb 
	 * 		An instance of the {@link TMDB} class
	 */
	public PersonCredits(TMDB tmdb) {
		super(tmdb, TMDBConstants.PERSON, TMDBConstants.CREDITS);		
	}

	/**
	 * Gets a {@link PersonCreditWrapper} object.
	 *
	 * @param personId 
	 * 		The Person id
	 * @param language 
	 * 		The language parameter tries to localize the movie data we return. If the 
	 * 		language being requested does not exist, the value will be left blank. 
	 * 		The expected value is a ISO 639-1 code
	 * @return 
	 * 		The <code>PersonCreditWrapper</code> object
	 * @throws Exception 
	 * 		If any kind off exception occurred
	 */
	public PersonCreditWrapper getPersonCreditWrapper(int personId, String language) throws Exception {
		URL personCreditURL = getUrl(String.valueOf(personId), language);
		PersonCreditWrapper personCreditWrapper = getJsonObject(personCreditURL, PersonCreditWrapper.class);
		return personCreditWrapper;
	}
}
